package com.fullstack.app.pages.home

import cats.effect.IO
import com.fullstack.app.App
import com.fullstack.app.pages.Page
import com.fullstack.app.pages.common.{Constants, Endpoint}
import com.fullstack.app.pages.components.home.HomeLayout
import io.circe.*
import io.circe.generic.auto.*
import io.circe.parser.*
import io.circe.syntax.*
import org.scalajs.dom.{console, document, html, window}
import tyrian.Html.*
import tyrian.cmds.Logger
import tyrian.http.{HttpError, Method, Response}

import tyrian.{CSS, Cmd, Html, Location, LocationDetails, Nav}
import com.fullstack.app.App.AppMsg.FollowExternalLink

/**
 * 首页
 *    展示最新文章列表
 */


case class UserPage(

                   ) extends Page:

  import HomePage.*
  import HomePage.HomePageMsg.*

  override def initCmd: Cmd[IO, App.Msg] =
    // 当点击某个类别后，再点击菜单栏的首页，需要把当前选择的样式清空
    Cmd.None

  override def update(msg: App.Msg): (Page, Cmd[IO, App.Msg]) =
    msg match

      case _ => (this, Cmd.None)
      
  end update

  override def view(): Html[App.Msg] =
    HomeLayout.view(
      div(
        div("User Page"),
        div(
          button( onEvent("click",
            e =>
              e.preventDefault()
              FollowExternalLink("https://www.baidu.com")
          ))("百度")
        )
      ),

    )

  end view
  

end UserPage



object UserPage:

  enum UserPageMsg extends App.Msg:
    case NoOp



  import UserPageMsg.*

  private object Endpoints:


  end Endpoints


  private object Commands:


  end Commands


end UserPage
